package com.project.handlChain;

import com.project.handle.TakewayRiderHandle;
import com.project.pojo.RiskController;
import com.project.utils.ErrorMessage;
import com.project.vo.TakewayRiderMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Component
public class TakewayRiderHandleChain {
    @Autowired
    List<TakewayRiderHandle> list = new ArrayList<>();

    boolean isContinue = true;

    public void handle(TakewayRiderMessage takewayRiderMessage, List<RiskController> riskRule, List<ErrorMessage> errorMessageList){
        if(!Objects.isNull(list)){

            for(TakewayRiderHandle takewayRiderHandle : list){

                takewayRiderHandle.takewayRiderRiskAssess(takewayRiderMessage, riskRule, errorMessageList);

                if (errorMessageList.size()>0){

                    break;
                }
            }
        }
    }

}
